import { computed } from 'vue';
import { picState } from './use-task.js';
import { keydownCondPairs } from '../common.js';

export const switchable = computed(() => ({
  prev: 0 < picState.value.i,
  next: picState.value.i + 1 < picState.value.list.length,
}));

export function usePicSwitch() {
  keydownCondPairs.push(
    [event => 'a' == event.key && !event.ctrlKey, () => switchable.value.prev && --picState.value.i],
    [event => 'd' == event.key && !event.ctrlKey, () => switchable.value.next && ++picState.value.i],
  );
}
